using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using System.Diagnostics;

namespace WPCoco
{
    /// <summary>
    /// Parent node of drewing hierachy
    /// </summary>
    public class Scene : AffineNode
    {
        /// <summary>
        /// Create an scene, the defaul size is the screen size and is created with anchor point at origin
        /// </summary>
        public Scene()
        {
            Width = Screen.Width; Height = Screen.Height;
            Anchor = new Vector2(0, 0);
        }

        public virtual void DoStartScene()
        {
            RaiseStartScene();
            IsRunning = true;
        }

        public virtual void DoEndScene()
        {
            RaiseEndScene();
            IsRunning = false;
        }

        #region Events

        /// <summary>
        /// Event for when the scene begins to run
        /// </summary>
        public event EventHandler StartScene;

        void RaiseStartScene() 
        {
            if (StartScene == null) return;
            StartScene(this, EventArgs.Empty);
        }

        /// <summary>
        /// Event for when the scene end running
        /// </summary>
        public event EventHandler EndScene;

        void RaiseEndScene()
        {
            if (EndScene == null) return;
            EndScene(this, EventArgs.Empty);
        }

        #endregion 

        /// <summary>
        /// Default behavior for back button 
        /// </summary>
        public virtual void Back()
        {
            Coco.Shared.Game.Exit();
        }
    }
}
